<?php
include "../lib/DAL/MonCTDT.php";
class MonCTDTBLL{
    function __construct(){
        
    }
    
    function __destruct(){
        
    }
    public function getListMonCTDT(){
        $sql ="select * from tbl_mon_ctdt";
        $result = mysql_query($sql) or die(mysql_error());
        $arr_ctdt = array();
        while($row = mysql_fetch_array($result)){
            $arr_ctdt[] = $this->setMonCTDTBLL($row);
        }
        return $arr_ctdt;
    }
    public function setMonCTDTBLL($row){
        $MonCTDT = new MonCTDT();
        $MonCTDT->setMonCTDTDAL($row['donvitinh'],$row['khoiluong'],$row['ma_ctdt'],$row['ma_loaimonhoc'],$row['ma_monhoc']);
        return $MonCTDT;
    }
    public function setAllCTDT($row){
        $allCTDT=new MonCTDT();
        $allCTDT->setAllCTDT($row['ma_mon_ctdt'],$row['ten_lmh'],$row['ten_mh'],$row['donvitinh'],$row['khoiluong'],$row['ten_td'],$row['ten_hedt'],$row['ten_nganh']);
        return $allCTDT;
    }
    public function getAll(){
        $sql="SELECT MC.ma_mon_ctdt,L.ten_lmh, M.ten_mh, MC.donvitinh, MC.khoiluong,T.ten_td,H.ten_hedt,N.ten_nganh
              FROM tbl_mon_ctdt as MC 
              INNER JOIN dm_loaimonhoc as L ON MC.ma_loaimonhoc=L.madm_lmh
              INNER JOIN dm_monhoc AS M ON MC.ma_monhoc=M.madm_mh 
              INNER JOIN tbl_ctdt AS CT ON MC.ma_ctdt=CT.ma_ctdt
              INNER JOIN dm_trinhdo as T ON CT.madm_td=T.madm_td
              INNER JOIN dm_hedaotao as H ON CT.madm_hdt=H.madm_hdt
              INNER JOIN dm_nganh as N ON CT.madm_nganh=N.madm_nganh";
        $result = mysql_query($sql) or die(mysql_error());
        $arr_ctdt = array();
        while($row = mysql_fetch_array($result)){
            $arr_ctdt[] = $this->setAllCTDT($row);
        }
        return $arr_ctdt;
    }
}
?>